 
 
 
 
 
 
 
use RFS_master_data, clear

 
 
     global vars3 "    N_aver N_coun   N_3hour N_BuSe N_IDB   " 
 
 global varIN2 "               D4_NEWS"
 
 /*
 note that D4_NEWS takes 4 values:
   4 --> more sophisticated, bigger news 
   3 --> more sophisticated, smaller news 
   2 --> less sophisticated, bigger news 
   1 --> less sophisticated, smaller news  
 */
 
  	 mat UNews_Sop = J(5,5,1)
	 mat UNews_Uns = J(5,5,1)

  foreach jj of global varIN2 {
  local gg = 1
   foreach j of global vars3 {
  di "`jj'_`j'"
  cap drop yy xx*
 gen yy = `j'
 gen xx = size
 gen xxActive = activeZ  
 qui winsor2 xx , replace cuts(1 99)
  qui winsor2 yy , replace cuts(1 99)
 
 cap estimates drop f*
 qui {
 	reghdfe yy  c.xx#i.`jj'     , absorb(st0_date#instrumentid#xxActive   call coun#xxActive      )    cluster(call   st0_date)
  estimates store ff1
    test 1.`jj'#c.xx = 2.`jj'#c.xx
    local gg2 = r(p)
    mat UNews_Uns[1,`gg'] = `gg2'
    test 3.`jj'#c.xx = 4.`jj'#c.xx
    local gg3 = r(p)
    mat UNews_Sop[1,`gg'] = `gg3'
	
 	reghdfe yy  c.xx#i.`jj'       , absorb(st0_date#instrumentid#xxActive    coun#xxActive   mm#call )    cluster(call   st0_date)
  estimates store ff2
    test 1.`jj'#c.xx = 2.`jj'#c.xx
    local gg2 = r(p)
    mat UNews_Uns[2,`gg'] = `gg2'
    test 3.`jj'#c.xx = 4.`jj'#c.xx
    local gg3 = r(p)
    mat UNews_Sop[2,`gg'] = `gg3'
	
 	reghdfe yy  c.xx#i.`jj'      , absorb(st0_date#instrumentid#xxActive  call   st0_date#coun#xxActive   )    cluster(call   st0_date)
  estimates store ff3
     test 1.`jj'#c.xx = 2.`jj'#c.xx
    local gg2 = r(p)
    mat UNews_Uns[3,`gg'] = `gg2'
    test 3.`jj'#c.xx = 4.`jj'#c.xx
    local gg3 = r(p)
    mat UNews_Sop[3,`gg'] = `gg3'
	
 	reghdfe yy  c.xx#i.`jj'       , absorb(st0_date#instrumentid#xxActive  mm#call st0_date#coun#xxActive  )    cluster(call   st0_date)
  estimates store ff4
     test 1.`jj'#c.xx = 2.`jj'#c.xx
    local gg2 = r(p)
    mat UNews_Uns[4,`gg'] = `gg2'
    test 3.`jj'#c.xx = 4.`jj'#c.xx
    local gg3 = r(p)
    mat UNews_Sop[4,`gg'] = `gg3'
	
 	reghdfe yy  c.xx#i.`jj'   /* if nn > 1  */    , absorb(st0_date#instrumentid#xxActive  mm#call st0_date#coun#xxActive call#coun)    cluster(call   st0_date)
  estimates store ff5
     test 1.`jj'#c.xx = 2.`jj'#c.xx
    local gg2 = r(p)
    mat UNews_Uns[5,`gg'] = `gg2'
    test 3.`jj'#c.xx = 4.`jj'#c.xx
    local gg3 = r(p)
    mat UNews_Sop[5,`gg'] = `gg3'
	
	}
  esttab ff*     ///
 , star("*" 0.1 "**" 0.05 "***" 0.01) b(%10.3f) t(%10.2f) scalars(N r2) sfmt(%10.3f)   replace
 
   esttab ff* using "RFSnews_`j'.tex"     ///
  , star("*" 0.1 "**" 0.05 "***" 0.01) b(%10.3f) t(%10.2f) scalars(N r2) sfmt(%10.3f)   replace
 
 local gg = `gg' + 1
  } 
  } 
	 
	 * SHOW THE P-values : 
		mat list UNews_Uns
		mat list UNews_Sop